"""
URL configuration for auto_dj_test project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.urls import path, include, re_path
from rest_framework.routers import DefaultRouter
from aweirunner.views import project, api, config, run, report,schedule

urlpatterns = [
    # 项目相关的接口
    path('project/', project.ProjectView.as_view({
        "get": "list",
        "post": "add",
        "patch": "update",
        "delete": "delete"
    })),
    # <int:pk> 部分是路径转换器，用于捕获一个整数值并将其分配给名为 'pk' 的变量
    path('project/<int:pk>/', project.ProjectView.as_view({"get": "single"})),
    path('dashboard/', project.DashBoardView.as_view({'get': 'get'})),
    # 访问统计相关接口
    path('visit/', project.VisitView.as_view({
        "get": "list",
    })),

    # # 二叉树接口地址
    path('tree/<int:pk>/', project.TreeView.as_view()),

    # api接口模板地址
    path('api/', api.APITemplateView.as_view({
        "get": "list",
        "post": "add",
    })),

    path('api/<int:pk>/', api.APITemplateView.as_view({
        "delete": "delete",
        "get": "single",
        "patch": "update",
        "post": "copy"
    })),

    path('api/tag/', api.APITemplateView.as_view({
        "patch": "add_tag",  # api修改状态
    })),

    path('api/move_api/', api.APITemplateView.as_view({
        "patch": "move",  # 修改api的位置
    })),

    # config接口地址
    path('config/', config.ConfigView.as_view({
        "post": "add",
        "get": "list",
        "delete": "delete"
    })),
    path('config/<int:pk>/', config.ConfigView.as_view({
        "post": "copy",
        "delete": "delete",
        "patch": "update",
        "get": "all"
    })),

    #全局变量
    path('variables/', config.VariablesView.as_view({
        "post": "add",
        "get": "list",
        "delete": "delete"
    })),

    path('variables/<int:pk>/', config.VariablesView.as_view({
        "delete": "delete",
        "patch": "update"
    })),

    # api 运行
    path('run_api_pk/<int:pk>/', run.run_api_pk),
    path('run_api_tree/', run.run_api_tree),
    path('run_api/', run.run_api),

    # 报告地址
    path('report/', report.ReportView.as_view({
        "get": "list"
    })),

    path('report/<int:pk>/', report.ReportView.as_view({
        "delete": "delete",
        "get": "look"
    })),

    # 定时任务相关接口
    path('schedule/', schedule.ScheduleView.as_view({
        "get": "list",
        "post": "add",
    })),

]
